<?php
	session_start();
	include("load-settings.php");

	if(!isset($_SESSION['user']))
		header("Location: login.php");

	$user = $_SESSION['user'];

	$result = mysql_query("SELECT * FROM user WHERE id = $user");
	$row = mysql_fetch_array($result);
	$access = $row['type'];

	$id = mysql_real_escape_string($_GET['id']);

	$result = mysql_query("SELECT * FROM ticket WHERE id = $id") or die(mysql_error());
	$row = mysql_fetch_array($result);

	$pass = false;

	if($user == $row['user'])
		$pass = true;
	else if($access == 2)
		$pass = true;
		
	if(!$pass)
		header("Location: home.php");

	mysql_query("UPDATE ticket SET status = 0 WHERE id = $id");

	header("Location: home.php");
?>